<?php
namespace Admin\Model;

use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

class Song implements InputFilterAwareInterface {

	public $id;
	public $title;
	public $abc;
	public $date_create;
	public $date_update;
	public $state;
	public $user_id;


	protected $inputFilter;

	public function exchangeArray($data) {
		$this->id = (isset($data['id'])) ? $data['id'] : null;
		$this->title = (isset($data['title'])) ? $data['title'] : null;
		$this->abc = (isset($data['abc'])) ? $data['abc'] : null;
		$this->date_create = (isset($data['date_create'])) ? $data['date_create'] : null;
		$this->date_update = (isset($data['date_update'])) ? $data['date_update'] : null;
		$this->state = (isset($data['state'])) ? $data['state'] : null;
		$this->user_id = (isset($data['user_id'])) ? $data['user_id'] : null;

	}


	public function setInputFilter(InputFilterInterface $inputFilter) {
		throw new \Exception('Not used');
	}

	public function getInputFilter() {
		if(!$this->inputFilter) {
			$inputFilter = new InputFilter();
			$factory = new InputFactory();
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'id',
					'required' => true,
					'filters'  => array(
							array('name' => 'Int'),
					),
			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'title',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
									),
							),
					),
					
			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'abc',
					'required' => false,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
									),
							),
					),
			)));
				
			$inputFilter->add($factory->createInput(array(
					'name'     => 'state',
					'required' => false,
			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'user_id',
					'required' => true,
					'filters'  => array(
							array('name' => 'Int'),
					),
			)));
						
			$this->inputFilter = $inputFilter;
			
		}
		return $this->inputFilter;
	}
	
	public function getArrayCopy()	{
		return get_object_vars($this);
	}

}